package com.pudu.json;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Administrator on 2016/8/17 0017.
 */
public class PuduJson {
    public JSONObject buildCoordinate(double x, double y, double z) throws JSONException {

        JSONObject jsonObject = new JSONObject();

        jsonObject.put("x",Math.rint(x * 1000)/1000);
        jsonObject.put("y",Math.rint(y * 1000)/1000);
        jsonObject.put("z",Math.rint(z * 1000)/1000);

        return jsonObject;
    }

    public JSONObject buildCoordinate(double[] coordinate) throws JSONException {

        JSONObject jsonObject = new JSONObject();

        jsonObject.put("x",Math.rint(coordinate[0] * 1000)/1000);
        jsonObject.put("y",Math.rint(coordinate[1] * 1000)/1000);
        jsonObject.put("z",Math.rint(coordinate[2] * 1000)/1000);

        return jsonObject;
    }
}